<template>
</template>
<script>
  import hospitalSet from "../../api/hosp/hospitalSet";

  export default {
    data(){
      return{
        hospitalSet:{}
      }
    },
    created() {
      if(this.$route.params && this.$route.params.id) {
        const id = this.$route.params.id
        this.getHospSet(id)
      }else{
        this.hospitalSet={}
      }
    },
    methods:{
      saveOrUpdate(){
        if(!this.hospitalSet.id){
          hospitalSet.saveHospSet(this.hospitalSet).then(result => {
            this.$message({
              type:'success',
              message:'添加成功',
            })
            this.$router.push({path:'/hospitalSet/list'})
          })
        }else{
          this.updata()
        }

      },
      getHospSet(id){
        hospitalSet.getHospSet(id).then(response => this.hospitalSet = response.data)
      },
      updata(){
        hospitalSet.updateHospSet(this.hospitalSet)
        .then(result => {
          this.$message({
            type:'success',
            message:'修改成功!'
          })
          this.$router.push({path:'/hospitalSet/list'})
        })
      }
    }
  }
</script>
